class Solution:
    def isNumber(self, s: str) -> bool:
        nums={str(i):1 for i in range(10)}
        signs={}
        signs["+"]=1
        signs["-"]=1
        special={}
        special["E"]=1
        special["e"]=1
        dot=0
        if s[0] not in nums and s[0] not in signs:
            return False
        for c in range(1,len(s)):
            if s[c] not in nums and s[c] not in signs and s[c] not in special and s[c]!=".":
                return False
            if s[c] in special:
                if s[c-1] not in nums:
                    return False
                if c==len(s)-1 or (s[c+1] not in nums and s[c+1] not in signs):
                    return False 
                dot=1
            if s[c] in signs:
                if s[c-1] not in special:
                    return False
            if s[c]=="+":
                return False
            if s[c]==".":
                if dot==1:
                    return False
                dot=1

        return True


s=Solution()
print(s.isNumber())